Field Value JQL Function
This document describes the fieldValue JQL function that allows you to retrieve and compare values from specific fields in issues matching a query.
Overview
The fieldValue JQL function enables you to extract and compare values from specific fields in issues that match a given query. This is particularly useful when you need to perform operations or comparisons on field values across multiple issues, especially when comparing values between different fields.
Available Function
fieldValue(subQuery, field)
Retrieves values from the specified field in issues matching the subquery.
Example:
"Story Points" > fieldValue("project = DEV", "estimate")
This query finds all issues where the Story Points value is higher than the estimate value of issues in the DEV project.
Usage Notes
- The function requires two arguments:
- A valid JQL subquery
- The name of the field to retrieve values from
- The function supports multiple operators:
=,!=(for exact matching)>,>=,<,<=(for numerical comparisons)in,not in(for list comparisons)
- Results are calculated based on the current values of the fields at the time of the query.
Syntax
The general syntax for using the fieldValue function in JQL is:
field [operator] fieldValue("jql_subquery", "field_name")
Where:
fieldis the field to compare againstoperatoris one of:=,!=,>,>=,<,<=,in,not injql_subqueryis a valid JQL query that returns a set of issuesfield_nameis the name of the field to retrieve values from
Field Types and Format Support
Supported Field Types
The fieldValue function works with various field types:
- Text fields (Summary, Description)
- Number fields
- Date fields
- User fields
- Label fields
- Custom fields of the above types
Custom Fields
When using custom fields:
- Always use the field's display name, not its ID
- Example: Use "Story Points" instead of "customfield_10001"
Field Value Formatting
- Text fields: Exact string matching
- Number fields: Numerical comparison
- Date fields: Date comparison (supports various date formats)
- User fields: Username or display name matching
- Label fields: Label name matching
Examples
Comparing Different Fields
Find issues where Story Points are higher than the estimate:
"Story Points" > fieldValue("project = DEV", "estimate")
Find issues where the reporter is the same as the assignee:
reporter = fieldValue("project = DEV", "assignee")
Find issues where the fix version matches the affected version:
fixVersion in fieldValue("project = DEV", "affectedVersion")
Find issues where resolutionDate is greater than the duedate: resolutionDate > fieldValue("project = DEV", "dueDate")
Best Practices
-
Always provide a valid JQL subquery:
- The subquery must be a valid JQL expression
- The subquery should be specific enough to return a manageable set of issues
-
Use appropriate field names:
- Use the field's display name
- Be aware of case sensitivity
- For custom fields, use the configured display name
-
Consider performance implications:
- Complex subqueries may impact query performance
- Very broad subqueries may slow down the search
- Consider using more specific subqueries to limit the result set
-
Combine with other JQL functions:
- The fieldValue function can be combined with other JQL functions
- Use parentheses to ensure proper operator precedence
Error Handling
The function will return an error if:
- The specified field name is not valid
- The JQL subquery is invalid
- The field name is not found in the system
- The operator is not compatible with the field type
- The comparison value is not in the correct format for the field type
Performance Considerations
-
Field Type Impact:
- Text field comparisons are generally faster than complex field types
- Date and number comparisons may require additional processing
- User and label field comparisons may involve additional lookups
-
Subquery Size:
- Large subqueries may impact performance
- Consider using more specific subqueries to limit the result set
-
Result Set Size:
- Large result sets may impact performance
- Use appropriate subqueries to limit the number of issues to search through
-
Field Value Size:
- Large text fields may impact performance
- Consider using more specific subqueries to limit the result set